<template>
	<div>
		<el-form>
			<el-form-item>
				<el-date-picker
				v-model="dates"
				type="date"
				value-format="yyyy-MM-dd HH:mm:ss"
				placeholder="选择日期时间">
				>
				</el-date-picker>
				<el-button type="primary" @click="selectinfo()">查询</el-button>
			</el-form-item>
			
			<el-table  :data="roomturn.list" style="100%">
				<el-table-column
				label="预定单号"
				prop="duenum"
				width="200"
				></el-table-column>
				<el-table-column
				label="房间号"
				prop="roomcode"
				width="80"
				></el-table-column>
				<el-table-column
				label="客房类型"
				prop="roomtype"
				width="80"
				></el-table-column>
				<el-table-column
				label="标准价格"
				prop="standardprice"
				width="80"
				></el-table-column>
				<el-table-column
				label="折后价格"
				prop="discountprice"
				width="80"
				></el-table-column>
				<el-table-column
				label="押金"
				prop="yajin"
				width="80"
				></el-table-column>
				<el-table-column
				label="预定人"
				prop="dueperson"
				width="80"
				></el-table-column>
				<el-table-column
				label="证件类别"
				prop="cretype"
				width="80"
				></el-table-column>
				<el-table-column
				label="证件号码"
				prop="crenum"
				width="120"
				></el-table-column>
				<el-table-column
				label="电话号码"
				prop="phone"
				width="120"
				></el-table-column>
				
				<el-table-column
				label="抵店时间"
				prop="arrivetime"
				width="200"
				></el-table-column>
				<el-table-column
				label="离店时间"
				prop="leavetime"
				width="200"
				></el-table-column>
				<el-table-column
				label="入住人数"
				prop="roomnum"
				width="80"
				></el-table-column>
				<el-table-column
				label="操作人"
				prop="caozuoren"
				width="80"
				></el-table-column>
				<el-table-column
				label="会员编号"
				prop="vipcode"
				width="80"
				></el-table-column>
				<el-table-column
				label="会员价格"
				prop="vipprice"
				width="80"
				></el-table-column>
				
				<el-table-column
				label="状态"
				width="120"
				prop="status"
				>
				<template slot-scope="scope">
					<template v-if="scope.row.status == 1">
					已预定
					</template>
					<template v-else-if="scope.row.status == 2">
					已取消
					</template>
					<template v-else-if="scope.row.status == 3">
					已入住
					</template>
				</template>
				</el-table-column>
				<el-table-column
				label="操作"
				width="120"
				>
				
				<template slot-scope="scope">
					<template v-if="scope.row.status == 1">
						<el-button type="warning" @click="turn(scope.row)">转入住</el-button>
					</template>
					<template v-else-if="scope.row.status == 2">
						<el-button type="info" disabled>已取消</el-button>
					</template>
					<template v-else-if="scope.row.status == 3">
						<el-button type="info" disabled>已入住</el-button>
					</template>
					</template>
				</el-table-column>
			</el-table>
			
			<el-dialog :visible.sync="disable" title="转入住" center>
				
				<el-form :inline="true" align="center" :model="type" :rules="rules" ref="loginForm">
			
				  <el-form-item label="客房编号" prop="roomcode">
				    <el-input v-model="type.roomcode" readonly ></el-input>
				  </el-form-item>
				  <el-form-item label="客房类型"  prop="roomtype">
				    <el-input v-model="type.roomtype" readonly ></el-input>
				  </el-form-item>
				  <el-form-item label="标准价格"  prop="standardprice">
				    <el-input  v-model="type.standardprice" readonly></el-input>
				  </el-form-item>
				  <el-form-item label="折后价格"  prop="discountprice">
				    <el-input  v-model="type.discountprice" readonly></el-input>
				  </el-form-item>
				  <el-form-item label="押金">
				    <el-input  v-model="type.yajin"></el-input>
				  </el-form-item>
				  <el-form-item label="预定人 "  prop="dueperson">
				   <el-input  v-model="type.dueperson"></el-input>
				  </el-form-item>
				  <el-form-item label="证件类别"  prop="cretype">
				    <el-input  v-model="type.cretype"></el-input>
				  </el-form-item>
				
				<el-form-item label="证件号码"  prop="crenum">
				    <el-input  v-model="type.crenum"></el-input>
				  </el-form-item>
				
				<el-form-item label="电话号码"  prop="phone">
				    <el-input  v-model="type.phone"></el-input>
				  </el-form-item>
				
				<el-form-item label="抵店时间"  prop="arrivetime">
				      <el-date-picker
				        v-model="type.arrivetime"
				        type="datetime"
						value-format="yyyy-MM-dd HH:mm:ss"
				        placeholder="选择日期时间">
				      </el-date-picker>
				 </el-form-item>
				  
				  <el-form-item label="离店时间 "  prop="leavetime">
				     <el-date-picker
						v-model="type.leavetime"
					      type="datetime"
					      value-format="yyyy-MM-dd HH:mm:ss"
					      placeholder="选择日期时间">
					 ></el-date-picker>
				    </el-form-item>
				
				<el-form-item label="入住人数"  prop="roomnum">
				    <el-input  v-model="type.roomnum"></el-input>
				  </el-form-item>
				
				<el-form-item label="操作员">
				    <el-input  v-model="type.caozuoren"></el-input>
				  </el-form-item>
				  
				  <el-form-item label="会员编号">
				      <el-input  v-model="type.vipcode"></el-input>
				    </el-form-item>
					
					<el-form-item label="会员价">
					    <el-input  v-model="type.vipprice"></el-input>
					  </el-form-item>
					  
					 <el-form-item label="提供早餐">
					    <el-select  v-model="type.breakfast">
							<el-option label="是" value="是"></el-option>
							<el-option label="否" value="否"></el-option>
						</el-select>
						
					    </el-form-item>
						<el-form-item label="定时叫醒">
						  <el-select  v-model="type.awaken">
								<el-option label="是" value="是"></el-option>
								<el-option label="否" value="否"></el-option>						
						  </el-select>
						 </el-form-item>
						 <el-form-item label="备注">
							 <el-input
								type="textarea"
							   :rows="2"
							   placeholder="请输入内容"
							   v-model="type.remarks">
							 ></el-input>
						 </el-form-item>
				<br />
					<el-form-item>
						<el-button type="warning" @click="disable = false">取消</el-button>
						<el-button  type="primary" @click="insertType()">入住</el-button>
					</el-form-item>
				
				</el-form>
			</el-dialog>
		</el-form>
		
	</div>
</template>

<script>
	export default{
		data(){
			return{
				//检查
				rules:{	
					roomcode:[
						{required:true,message:'不能空',trigger:['blur','change']},
					],
					roomtype:[
						{required:true,message:'不能空',trigger:['blur','change']},
					],
					standardprice:[
						{required:true,message:'不能空',trigger:['blur','change']}
					],
					discountprice:[
						{required:true,message:'不能空',trigger:['blur','change']},
					],
					cretype:[
						{required:true,message:'不能空',trigger:['blur','change']},
					],
					dueperson:[
						{required:true,message:'不能空',trigger:['blur','change']}
					],
					crenum:[
						{required:true,message:'不能空',trigger:['blur','change']},
					],
					phone:[
						{required:true,message:'不能空',trigger:['blur','change']},
					],
					roomnum:[
						{required:true,message:'不能空',trigger:['blur','change']}
					],
					
					leavetime:[
						{required:true,message:'不能空',trigger:['blur','change']}
					]
				},
				//输入时间得到预定
				dates:'',
				roomturn:{
					list:[]
				},
				type:{},
				disable: false
			}
		},
		methods:{
			//查找预定订单
			selectinfo(){
				if(this.dates){
					let url ="roominfo/selectTime"
					axios.post(url,`infodate=${this.dates}`).then(resp=>{
							this.roomturn.list=resp.data.data
							
							if(this.roomturn.list.length == 0){
								this.$alert("今天没有预定哦！");
							}else{
								
							}
							console.log(this.roomturn);
					})
				}else{
					this.$alert("输入时间哦！");
				}
				},
				//转入住
			turn(row){
					this.disable =true
					console.log(row);
					let ss= row
					this.type = ss
					
				},
		//插入
			insertType(){
				this.$refs["loginForm"].validate(valid=>{
					if(valid){
						let url ="Checkin/insert"
						axios.post(url,this.type).then(resp=>{
							if(resp.data.data == 1){
								this.$alert("入住成功！")
								this.type.status = 3
								let url ="roominfo/update"
								axios.post(url,this.type).then(resp=>{
									if(resp.data.data == 1){
										this.type={}
										this.disable = false
									}
								})
							}
						})
					}})
			}
		
		}
	}
</script>

<style>
</style>
